--???????? ?? ????? ?? ECS http://pastebin.com/Xn8THcUC
os.loadAPI("/System/API/windows")
os.loadAPI("/System/API/sysbar")
os.loadAPI("/System/API/image")
local xSize, ySize = term.getSize()
local xCenter, yCenter = math.floor(xSize/2), math.floor(ySize/2)
local run = true
local digits = {'0.png','1.png','2.png','3.png','4.png','5.png','6.png','7.png','8.png','9.png','dots.png'}
local comp = 0
if xSize > 30 then comp = 1 end

local function clear(color)
	term.setBackgroundColor(color)
	term.clear()
end

local function fadeIn(time)
 for i=1,ySize-1 do
  paintutils.drawLine(1,i,xSize,i,mainColor)
  sleep(time)
 end
end

local function fadeOut(time)
 for i=0,xSize do
  paintutils.drawLine(xSize-i,0,xSize-i,ySize-1,colors.black)
  paintutils.drawLine(xSize-i,1,xSize,1,colors.black)
  sleep(time)
 end
	term.setCursorPos(1,1)
	term.setTextColor(colors.white)
end

local function text(text,x,y)
	term.setCursorPos(x,y)
	term.write(text)
end

local sysBar = function()
 term.setTextColor(colors.black)
 term.setBackgroundColor(colors.white)
 sysbar.draw(colors.white,colors.black,noty,true,false,false)
end

local formatTime = function(nTime)
    local nHour = math.floor(nTime)
    local nMinute = math.floor((nTime - nHour)*60)
    return nHour, nMinute
end

local drawDots = function()
	while true do
		image.draw(xCenter,yCenter-3,'/System/clocks/'..digits[11])
		sleep(0.5)
		paintutils.drawFilledBox(xCenter,yCenter-3,xCenter+1,yCenter+3,style)
		sleep(0.5)
	end
end

local globalClock = function(time)
	while true do
		local globalTime = os.time()
		local hour, minute = formatTime(globalTime)
		paintutils.drawFilledBox(xCenter-10,yCenter-3,xCenter-1,yCenter+3,style)
		paintutils.drawFilledBox(xCenter+3,yCenter-3,xCenter+11,yCenter+3,style)
		image.draw(xCenter-10,yCenter-3,'/System/clocks/'..digits[math.floor(hour/10)+1])
		image.draw(xCenter-5,yCenter-3,'/System/clocks/'..digits[math.floor(hour%10)+1])
		image.draw(xCenter+3,yCenter-3,'/System/clocks/'..digits[math.floor(minute/10)+1])
		image.draw(xCenter+8,yCenter-3,'/System/clocks/'..digits[math.floor(minute%10)+1])
		sleep(1)
	end
end

local function redraw()
 clear(style)
 sysBar()
end

local function touch()
 while true do
  --clock()
  event, side, x, y = os.pullEvent()
  if event == "mouse_click" then
   if sysbar.back(x,y) then
    break
   elseif sysbar.home(x,y) then
    home = true
    break
   end
  end
 end
end

redraw()
parallel.waitForAny(globalClock,touch,drawDots)
clear(colors.black)